﻿using BullsAndCows;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace BullsAndCowsTests
{
    [TestClass()]
    public class UserTest
    {
        [TestMethod()]
        public void UserConstructorTest()
        {
            User target = new User();
            Assert.AreEqual("", target.Name, "Incorrect name!");
            Assert.AreEqual(0, target.Guesses, "Wrong number of guesses!");
            Assert.AreEqual(0, target.Cheats, "Wrong number of cheats!");
        }

        [TestMethod()]
        public void GuessesNormalTest()
        {
            User target = new User();
            int expected = 10;
            int actual;
            target.Guesses = expected;
            actual = target.Guesses;
            Assert.AreEqual(expected, actual, "Number of guesses differs!");
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentException))]
        public void GuessesInvalidInputTest()
        {
            User target = new User();
            int expected = -10;
            target.Guesses = expected;
        }

        [TestMethod()]
        public void CheatsNormalTest()
        {
            User target = new User();
            int expected = 5;
            int actual;
            target.Cheats = expected;
            actual = target.Cheats;
            Assert.AreEqual(expected, actual, "Number of cheats differs!");
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentException))]
        public void CheatsInvalidInputTest()
        {
            User target = new User();
            int expected = -1;
            target.Cheats = expected;
        }

        [TestMethod()]
        public void NameNormalTest()
        {
            User target = new User();
            string expected = "Bai Ivan";
            string actual;
            target.Name = expected;
            actual = target.Name;
            Assert.AreEqual(expected, actual, "Name differs!");
        }

        [TestMethod()]
        public void IsAllowedToScoreBoardTrueTest()
        {
            User target = new User();
            bool expected = true;
            bool actual;
            actual = target.IsAllowedToScoreBoard();
            Assert.AreEqual(expected, actual, "Should be allowed to Score board!");
        }

        [TestMethod()]
        public void IsAllowedToScoreBoardFalseTest()
        {
            User target = new User();
            target.Cheats = 5;
            bool expected = false;
            bool actual;
            actual = target.IsAllowedToScoreBoard();
            Assert.AreEqual(expected, actual, "Should not be allowed to Score board!");
        }
    }
}